package io.bhex.sdk.account;

import java.io.File;

import io.bhex.baselib.network.BParamsBuilder;
import io.bhex.baselib.network.HttpUtils;
import io.bhex.baselib.network.listener.SimpleResponseListener;
import io.bhex.baselib.network.params.GetParams;
import io.bhex.baselib.network.params.PostParams;
import io.bhex.baselib.network.response.ResultResponse;
import io.bhex.sdk.Urls;
import io.bhex.sdk.account.bean.kyc.KycLevelBean;
import io.bhex.sdk.account.bean.kyc.KycLevelConfigResponse;
import io.bhex.sdk.account.bean.kyc.KycLevelsResponse;
import io.bhex.sdk.account.bean.kyc.KycVideoUploadResponse;
import io.bhex.sdk.account.bean.kyc.LvTwoSubmitResponse;

/**
 * ================================================
 * 作   者：ppzhao
 * 创建时间：2019-11-19
 * 邮   箱：
 * 描   述：
 * ================================================
 */

public class KycApi {

    //获取机构KYC级别配置
    public static void RequestKycConfig(String countryCode, int kycLevel, SimpleResponseListener<KycLevelBean> listener) {
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_KYC_CONFIG)
                .addParam("country_code",countryCode)
                .addParam("kyc_level",kycLevel)
                .build();
        HttpUtils.getInstance().request(params, KycLevelBean.class,listener);
    }

    //获取用户KYC级别信息
    public static void RequestKycLevels(SimpleResponseListener<KycLevelsResponse> listener) {
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_KYC_LEVEL)
                .build();
        HttpUtils.getInstance().request(params, KycLevelsResponse.class,listener);
    }

    /**
     * 用户KYC基础认证
     *
     * 证件类型 1=身份证 2=驾照 3=护照 5=其它
     */
    public static void RequestKycBasicVerify(String countryCode,String name,String firstName,String secondName,int cardType,String cardNo,SimpleResponseListener<ResultResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_KYC_BASIC_VERIFY)
                .addParam("country_code",countryCode)
                .addParam("name",name)
                .addParam("first_name",firstName)
                .addParam("second_name",secondName)
                .addParam("card_type",cardType)
                .addParam("card_no",cardNo)
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class,listener);
    }

    /**
     * 用户证件照KYC认证
     *
     * @param listener
     */
    public static void RequestKycPhotoVerify(String cardFrontUrl,String cardBackUrl,String cardHandUrl,SimpleResponseListener<LvTwoSubmitResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_KYC_PHOTO_VERIFY)
                .addParam("card_front_url",cardFrontUrl)
                .addParam("card_back_url",cardBackUrl)
                .addParam("card_hand_url",cardHandUrl)
                .build();
        HttpUtils.getInstance().request(params, LvTwoSubmitResponse.class,listener);
    }

    /**
     * 获取人脸核身KYC准备信息
     *
     * @param listener
     */
    public static void RequestKycFacePrepareSdk(String orderNo,SimpleResponseListener<ResultResponse> listener) {
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_KYC_FACE_PREPARE_SDK)
                .addParam("order_no",orderNo)
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class,listener);
    }

    /**
     * 人脸核身KYC认证
     *
     * @param listener
     */
    public static void RequestKycFaceVerify(String orderNo,SimpleResponseListener<ResultResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_KYC_FACE_VERIFY)
                .addParam("order_no",orderNo)
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class,listener);
    }

    /**
     * 用户KYC视频上传
     *
     * @param listener
     */
    public static void RequestKycVideoUpload(File videoFile, SimpleResponseListener<KycVideoUploadResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_KYC_VIDEO_UPLOAD)
                .addFile("upload_video_file",videoFile)
                .build();
        HttpUtils.getInstance().request(params, KycVideoUploadResponse.class,listener);
    }

    /**
     * 用户视频KYC认证
     *
     * @param listener
     */
    public static void RequestKycVideoVerify(String videoUrl,SimpleResponseListener<ResultResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_KYC_VIDEO_VERIFY)
                .addParam("video_url",videoUrl)
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class,listener);
    }
}
